#include "hdrform.h"
#include "ui_hdrform.h"
#include <QKeyEvent>
#include <QSerialPort>
#include <QDebug>
#include "uart.h"
hdrForm::hdrForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::hdrForm)
{
    ui->setupUi(this);
    this->setStyleSheet("background-color: rgb(0, 186, 238);");
    box_sel=NULL;
    QImage *img=GetLogo();
    if(img!=NULL)
        ui->label_Logo->setPixmap(QPixmap::fromImage(*img).scaled(ui->label_Logo->size()));

}

hdrForm::~hdrForm()
{
    delete ui;
}
void hdrForm::keyPressEvent(QKeyEvent *event)
{
    int key=event->key();
  qDebug()<< key;
//  printf("key= %d\n",key);
    if(key==Qt::Key_F12||key==Qt::Key_Exit)
    {
        if(ShowPreWin())
            this->hide();
    }
    else
        if(ShowWin(key,0))
           this->hide();

}

void hdrForm::on_checkBox_clicked()
{
    sendUartCmd(hdr_setup,HDR_OFF);
    SelBox(ui->checkBox);
}

void hdrForm::on_checkBox_2_clicked()
{
    sendUartCmd(hdr_setup,HDR_10);
    SelBox(ui->checkBox_2);
}

void hdrForm::on_checkBox_3_clicked()
{
    sendUartCmd(hdr_setup,HLG);
    SelBox(ui->checkBox_3);
}

void hdrForm::on_checkBox_6_clicked()
{
    sendUartCmd(hdr_setup,HDR_CUSTOM1);
    SelBox(ui->checkBox_6);
}

void hdrForm::on_checkBox_7_clicked()
{
    sendUartCmd(hdr_setup,HDR_CUSTOM2);
    SelBox(ui->checkBox_7);
}

void hdrForm::on_checkBox_8_clicked()
{
    sendUartCmd(hdr_setup,HDR_CUSTOM3);
    SelBox(ui->checkBox_8);
}

void hdrForm::on_checkBox_9_clicked()
{
    sendUartCmd(hdr_setup,HDR_CUSTOM4);
    SelBox(ui->checkBox_9);
}

void hdrForm::on_checkBox_10_clicked()
{
    sendUartCmd(hdr_setup,HDR_CUSTOM5);
    SelBox(ui->checkBox_10);
}

void hdrForm::on_checkBox_11_clicked()
{
    sendUartCmd(hdr_setup,HDR_CUSTOM6);
    SelBox(ui->checkBox_11);
}

void hdrForm::on_checkBox_12_clicked()
{
    sendUartCmd(hdr_setup,HDR_CUSTOM7);
    SelBox(ui->checkBox_12);
}

void hdrForm::on_checkBox_13_clicked()
{
    sendUartCmd(hdr_setup,HDR_CUSTOM8);
    SelBox(ui->checkBox_13);
}

